package v1

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

type ClearReq struct {
	g.Meta `path:"/auth/clear" tags:"清除接口" method:"get" summary:"清除接口"`
}
type ClearRes struct {
	Msg string `json:"msg"`
}

type GetUserInfoReq struct {
	g.Meta `path:"/auth/getUserInfo" tags:"获取当前登录人" method:"get" summary:"获取当前登录人"`
}
type GetUserInfoRes struct {
	User interface{} `json:"user"`
}

type Oauth2ConfigReq struct {
	g.Meta `path:"/auth/oauth2-config" tags:"auth接口" method:"get" summary:"获取oauth2相关配置"`
}
type Oauth2ConfigRes struct {
	Enable           bool   `json:"enable"` // 是否启用
	Name             string `json:"name"`
	ClientId         string `json:"clientId"`
	ClientSecret     string `json:"clientSecret"`
	AuthorizationURL string `json:"authorizationURL"`
	AccessTokenURL   string `json:"accessTokenURL"`
	RedirectURL      string `json:"redirectURL"`
	Scopes           string `json:"scopes"`
	ResourceURL      string `json:"resourceURL"`
	UserIdentifier   string `json:"userIdentifier"`
	AutoRegister     bool   `json:"autoRegister"` // 是否自动注册
}

type EnabledReq struct {
	g.Meta `path:"auth/ldap/enabled" tags:"auth接口" method:"get" summary:"ldap登录配置"`
}
type EnabledRes bool

type LoginReq struct {
	g.Meta   `path:"auth/accounts/login" tags:"auth接口" method:"post" summary:"账户密码登录接口"`
	Username string `p:"username" v:"required"`
	Password string `p:"password" v:"required"`
	Captcha  string `p:"captcha"`
	Cid      string `p:"cid"`
}
type LoginRes struct {
	LastLoginIp   string      `json:"lastLoginIp"`
	LastLoginTime *gtime.Time `json:"lastLoginTime"`
	Name          string      `json:"name"`
	Otp           string      `json:"otp"`
	RefreshToken  string      `json:"refresh_token"`
	Token         string      `json:"token"`
	Username      string      `json:"username"`
}
